import axios from 'axios'
import message from '../../components/message'

/**
 * ======================================================================
 * 【基本说明】：
 * 网络请求模块,基于axios封装
 *
 * Created by Major_ on 18-9-12.
 * ======================================================================
 */

// axios.defaults.timeout = 10000;
axios.defaults.baseURL = "http://39.108.180.1:10094/index.php/";

const headers = {
  'content-type': 'application/octet-stream'
}

const upload = {
  /** post 请求
   * @param  {接口地址} url
   * @param  {请求参数} params
   */
  async post(url, data) {
    try {
      let res = await axios.post(url, data, {
        headers: headers
      })
      return new Promise((resolve, reject) => {
        resolve(res.data)
      })
    } catch (err) {
      message.toast({
        message: `服务器出错!`
      })
    }
  },
}

export default upload
